﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Jumpton.SFA.Server.Entity;
using Jumpton.Data;
using Jumpton.Persistent;

namespace Jumpton.SFA.Server.BusinessRule.System
{
    public class TableConfigManager
    {
        /// <summary>
        /// 根据主键获取数据
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public TableConfig Load(int ID)
        {
            return (TableConfig)ObjectRow.Load(typeof(TableConfig),"this.ID=" + ID);
        }

        public ObjectTable LoadALL()
        {
            return new ObjectTable(typeof(TableConfig), "IsActive=1");
        }

        /// <summary>
        /// 根据表名来获取所有的冗余行
        /// </summary>
        /// <param name="TableName"></param>
        /// <returns></returns>
        public ObjectTable LoadByTable(string TableName)
        {
            return new ObjectTable(typeof(TableConfig), "IsActive=1 and TableName='" + TableName + "'");
        }
        /// <summary>
        /// 保存记录
        /// </summary>
        /// <param name="config"></param>
        public void Save(TableConfig config)
        {
            if (config != null)
            {
                config.LastUpdate = DateTime.Now;
                config.Save();
            }
        }
    }
}
